package xpn.platform.modules.workflow.definition.process;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.data.rest.core.config.Projection;
import xpn.platform.common.repository.XpnRepository;

/**
 * 流程定义
 *
 * @author bobatkm
 * @version 2017年8月31日 上午9:26:35
 */
@RepositoryRestResource(path = "workflow_definition_processes", excerptProjection = ProcessDefaultProjection.class)
@SuppressWarnings("unchecked")
public interface ProcessDAO extends XpnRepository<java.lang.Process, Long> {
    /*
     * 保存权限控制
     */
    @RequiresPermissions("workflow.admin")
    @Override
    java.lang.Process save(java.lang.Process entity);

    /*
     * 删除权限控制
     */
    @RequiresPermissions("workflow.admin")
    @Override
    void delete(java.lang.Process entity);

    /**
     * 根据名称模糊查找，忽略大小写
     */
    @RestResource(path = "byName", rel = "byName")
    Page<java.lang.Process> findByName(@Param("params") String params, Pageable pageable);

    /**
     * 根据描述模糊查找，忽略大小写
     */
    @RestResource(path = "byDescription", rel = "byDescription")
    Page<java.lang.Process> findByDescription(@Param("params") String params, Pageable pageable);

    /**
     * 根据名称精确匹配第一条记录
     *
     * @param name
     * @return
     */
    java.lang.Process findFirstByName(String name);

    /**
     * 根据编号精确匹配第一条记录
     *
     * @param no
     * @return
     */
    java.lang.Process findFirstByNo(String no);
}

/**
 * 缺省投影
 *
 * @author duwei
 */
@Projection(name = "default", types = {java.lang.Process.class})
interface ProcessDefaultProjection {

    Long getId();

    String getName();

    String getNo();

    String getSortNo();

    Long getInitStateId();

    String getStartAuthorizationRule();

    String getDescription();
}